package com.c2b.algorithm.leetcode.base;

import java.util.List;

public class Printer {

    public static void printListNode(ListNode head) {
        ListNode currNode = head;
        while (currNode != null) {
            System.out.print(currNode.val + " -> ");
            currNode = currNode.next;
        }
        System.out.println("null");
    }

    public static void printListInteger(List<Integer> listList) {
        if (listList == null || listList.size() == 0) {
            System.out.println("[]");
            return;
        }
        System.out.print("[");
        for (int i = 0; i < listList.size(); i++) {
            if (i == listList.size() - 1) {
                System.out.print(listList.get(i));
            } else {
                System.out.print(listList.get(i) + ",");
            }
        }
        System.out.println("]");
    }

    public static void printListString(List<String> listList) {
        if (listList == null || listList.size() == 0) {
            System.out.println("[]");
            return;
        }
        System.out.print("[");
        for (int i = 0; i < listList.size(); i++) {
            if (i == listList.size() - 1) {
                System.out.print(listList.get(i));
            } else {
                System.out.print(listList.get(i) + ",");
            }
        }
        System.out.println("]");
    }

    public static void printListListInteger(List<List<Integer>> listList) {
        if (listList == null || listList.size() == 0) {
            System.out.println();
            return;
        }
        for (int i = 0; i < listList.size(); i++) {
            System.out.print("[");
            int size = listList.get(i).size();
            for (int i1 = 0; i1 < size; i1++) {
                if (i1 == size - 1) {
                    System.out.print(listList.get(i).get(i1));
                } else {
                    System.out.print(listList.get(i).get(i1) + ",");
                }
            }
            if (i == listList.size() - 1) {
                System.out.print("]");
            } else {
                System.out.print("], ");
            }
        }
        System.out.println();
    }

    public static void printArrayInt(int[] nums) {
        System.out.print("[");
        for (int i = 0; i < nums.length; i++) {
            if (i != nums.length - 1) {
                System.out.print(nums[i] + ",");
            } else {
                System.out.print(nums[i]);
            }
        }
        System.out.println("]");
    }
}
